package cn.com.oil.controller;

import cn.com.oil.common.model.FileSystemNode;
import cn.com.oil.common.result.Result;
import cn.com.oil.common.util.FileUtils;
import cn.com.oil.service.ProjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping(path = "/project")
public class ProjectController {


    @Autowired
    private ProjectService projectService;

    @GetMapping(value = "/create/{name}")
    public Result<String> creatProject(@PathVariable String name) {
        return projectService.createProject(name);
    }


    @GetMapping(value = "/menu/{name}")
    public Result<FileSystemNode> getMenu(@PathVariable String name) {
        return Result.success(FileUtils.getMenu(name));
    }


    @GetMapping(path = "/test")
    public  Result<String>  test() throws Exception {
        return Result.success("ok");
    }


    @GetMapping(path = "/getWindows")
    public Result<String> getWindows() {
        return Result.success("OK");
    }
}
